import Vue from 'vue'
import Router from 'vue-router'
import Home from '@v/Home'
import Login from '@v/Login'


Vue.use(Router)
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/editpsd',
      name: 'editpsd',
      component: () => import('@v/Editpsd.vue'),
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '*',
      component: Login
    },

    {
      path: '/home',
      name: 'name',
      component: Home,
      redirect:() => import('@v/desk/Workbench.vue'),
      children: [
        {
          path: '/workbench',
          name: 'workbench',
          component: () => import('@v/desk/Workbench.vue'),
          meta: {
            title: '工作台',
          }
        },
        {
          path: '/message',
          name: 'message',
          component: () => import('@v/news/Message.vue'),
          meta: {
            title: '消息通知',
          }
        },
        {
          path: '/truck',
          component: () => import('@v/company/Index.vue'),
          redirect:() => import('@v/company/trucks/detail/Trucks.vue'),
          meta: {
            title: '企业管理',
          },
          children:[
            {
              path: '/truck',
              component: () => import('@v/company/trucks/Index.vue'),
              redirect: () => import('@v/company/trucks/detail/Trucks.vue'),
              meta: {
                title: '车辆管理',
              },
              children:[
                {
                  path: '/truck',
                  name: 'trucks',
                  component: () => import('@v/company/trucks/detail/Trucks.vue'),
                },
                {
                  path: '/trucksDetail',
                  name: 'trucksDetail',
                  component: () => import('@v/company/trucks/detail/Trucksdetail.vue'),
                  meta: {
                    title: '车辆录入',
                  }
                }
              ]
            },

            {
              path: '/driver',
              component: () => import('@v/company/drivers/Index.vue'),
              redirect: () => import('@v/company/drivers/detail/Drivers.vue'),
              meta: {
                title: '司机管理',
              },
              children:[
                {
                  path: '/driver',
                  name: 'driver',
                  component: () => import('@v/company/drivers/detail/Drivers.vue'),
                },
                {
                  path: '/driverdetail',
                  name: 'driverdetail',
                  component: () => import('@v/company/drivers/detail/Detaildriver.vue'),
                  meta: {
                    title: '司机录入',
                  }
                }
              ]
            },

            {
              path: '/invoice_get',
              name: 'invoice_get',
              component: () => import('@v/company/Invoice.vue'),
              meta: {
                title: '发票抬头管理',
              }
            },
            {
              path: '/operation_get',
              name: 'operation_get',
              component: () => import('@v/company/Postaddress.vue'),
              meta: {
                title: '邮寄地址管理',
              }
            },
            
          ]
        },
        {
          path: '/orders',
          component: () => import('@v/orders/Index.vue'),
          redirect: () => import('@v/orders/page/detail/Orders.vue'),
          meta: {
            title: '运单管理',
          },
          children:[
            {
              path: '/orders',
              component: () => import('@v/orders/page/Index.vue'),
              redirect: () => import('@v/orders/page/detail/Orders.vue'),
              children:[
                {
                  path: '/orders',
                  name: 'orders',
                  component: () => import('@v/orders/page/detail/Orders.vue'),
                  meta: {
                    title: '运单跟踪',
                  },
                },
                {
                  path: '/editorders',
                  name: 'editorders',
                  component: () => import('@v/orders/page/detail/Editorders.vue'),
                  meta: {
                    title: '运单修改',
                  }
                },
                
              ]
            },
            {
              path: '/orders_error',
              component: () => import('@v/orders/page/Index.vue'),
              redirect: () => import('@v/orders/page/errorOrder/Ordererror.vue'),
              meta: {
                title: '异常运单',
              },
              children:[
                {
                  path: '/orders_error',
                  name: 'orders_error',
                  component: () => import('@v/orders/page/errorOrder/Ordererror.vue'),
                  meta: {
                    title: '异常运单',
                  },
                },
                {
                  path: '/errorders',
                  name: 'errorders',
                  component: () => import('@v/orders/page/errorOrder/Editorders.vue'),
                  meta: {
                    title: '运单修改',
                  }
                },
              ]
            },
            {
              path: '/orders_add',
              name: 'orders_add',
              component: () => import('@v/orders/page/Ordersdetail.vue'),
              meta: {
                title: '运单录入',
              }
            },
          ]
        },
      ]
    },
  ]
})
